<?php

include("sqlconnect.php");

$fname=$_POST['user_fname'];
$lname=$_POST['user_lname'];
$email=$_POST['email_id'];
$pass=sha1($_POST['password']);
$repass=sha1($_POST['repass']);
$date=$_POST['date'];
$month=$_POST['month'];
$year=$_POST['year'];
$sex=$_POST['gender'];
$secque=$_POST['sec_q'];
$ans=$_POST['sec_a'];
$slash='/';
echo("$slash");
$combine=$year . $slash . $month . $slash . $date;
echo("$combine");


// date of joining
$sys = date("Y/m/d");


$ch1 = 'unchecked';
$ch2 = 'unchecked';
$ch3 = 'unchecked';
$ch4 = 'unchecked';
$ch5 = 'unchecked';



if (isset($_POST['camera']))
{
	$ch1 = $_POST['camera'];

	if ($ch1 == 'camera')
	{
		$ch1 = 'checked';
		//echo "$ch1";
	}
}
else
$ch1='no';

if (isset($_POST['television'])) 
{
	$ch2 = $_POST['television'];

	if ($ch2 == 'television') 
	{
		$ch2 = 'checked';
		//echo "$ch2";
	}
}
else
$ch2='no';

if (isset($_POST['speaker'])) 
{
	$ch3 = $_POST['speaker'];

	if ($ch3 == 'speaker') 
	{
		$ch3 = 'checked';
		//echo "$ch3";
	}
}
else
	$ch3='no';

if (isset($_POST['phone'])) 
{
	$ch4 = $_POST['phone'];

	if ($ch4 == 'phone') 
	{
		$ch4 = 'checked';
		//echo "$ch5";
	}
}else

$ch4='no';


$query=("INSERT INTO users(user_fname, user_lname, email_id, password,user_dob,user_doj, gender, sec_q, sec_a) VALUES('$fname','$lname', '$email', '$pass','$combine','$sys', '$sex','$secque', '$ans')");

mysql_query($query) or die("error in inserting");


$query1 = "SELECT * FROM users where user_fname= '$fname'";
$result1=mysql_query($query1) or die("login session error in inserting");
$row1=	mysql_fetch_object($result1);
$user_id = $row1->user_id;
session_start();

  $_SESSION['usrid'] = $user_id;
  $_SESSION['fname'] = $fname;
  $_SESSION['lname'] = $lname;
  $_SESSION['loginstatus']=1;

//echo "successfully inserted in table";

header('Location: /theshoppingbuzz/afterlogin.html');

?>
